from myelin.rdf.Ns import RDFS_SEEALSO
from myelin.rdf.bindery.Model import OBJECT_TYPE_RESOURCE
from nodetypes.ntypes.Document.showBase.RDF import Transform, Document


class Document(Document):    
    
    containsKey = u'mPrimary_Topic'
    
    def getContainedNodeInitializer(self, context):
        def init(n, repo=context.repo):
            print "INIT: ", n.rdf_value
            try:
                r = repo.fetchResourceByUri(n.rdf_value)
            except:
                return n
            
            n.rdf_reset(
                n.rdf_initDriver(r.getModel().driver)
            )
            n.rdf_domain = r.getAbsolutePathAsUri()
            return n
        return init

class Transform(Transform):
    
    newDocument = Document